package com.example.testbroadcast.db;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wly on 2019/5/30.
 */

public class BlackDAO {
    BlackDBHelper helper;
    public BlackDAO(Context context){
        helper=new BlackDBHelper(context);
    }
    public void insert(String phone){
        SQLiteDatabase db=helper.getReadableDatabase();
        ContentValues values=new ContentValues();
        values.put("phone",phone);
        db.insert("info",null,values);
        db.close();
    }
    public List<String> queryAll(){
        SQLiteDatabase db=helper.getReadableDatabase();
        Cursor cursor=db.query("info",null,null,null,null,null,null,null);
        ArrayList<String> list=new ArrayList<>();
        while(cursor.moveToNext()){
            list.add(cursor.getString(0));

        }
        cursor.close();
        db.close();
        return list;
    }
}
